package com.hanoiwiki.manager.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.hanoiwiki.dao.UserDAO;
import com.hanoiwiki.exception.DataAccessException;
import com.hanoiwiki.manager.UserManager;
import com.hanoiwiki.model.User;

@Component
@Transactional
public class UserManagerImpl extends BaseManagerImpl implements UserManager {
	
	@Autowired
	private UserDAO userDAO;	

	@Override
	public void save(User user) {
		try {
			userDAO.save(user);
		} catch (DataAccessException e) {
			log.error(" ",e);
		}		
	}

	@Override
	public User get(Integer id) {
		try {
			return userDAO.get(id);
		} catch (DataAccessException e) {
			log.error(" ",e);
		}
		return null;
	}

	@Override
	public List<User> getList() {		
		try {
			return userDAO.getList();
		} catch (DataAccessException e) {
			log.error(" ",e);
		}
		return null;
	}

	@Override
	public void remove(Integer id) {
		try {
			userDAO.remove(id);
		} catch (DataAccessException e) {
			log.error(" ",e);
		}		
	}

	@Override
	public void update(User user) {
		try {
			userDAO.update(user);
		} catch (DataAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
	}
}
